﻿namespace com.crownpack.Extensions.SharePointExtensions
{
    using System.Linq;

    using Microsoft.SharePoint;

    public static class SPViewCollectionExtensions
    {
        #region Methods

        public static bool ExistsByTitle( this SPViewCollection views, string title )
        {
            return views.Cast<SPView>( ).ToList( ).Exists( a => a.Title.Equals( title ) );
        }

        public static SPView GetByTitle( this SPViewCollection views, string title )
        {
            return views.ExistsByTitle( title ) ? views[ title ] : null;
        }

        #endregion Methods
    }
}